package com.spring.demo.core.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.spring.demo.core.dao.IPingDao;
import com.spring.demo.core.entity.Ping;
import com.spring.demo.core.service.IPingService;

@Service
public class PingService implements IPingService {

	@Autowired
	private IPingDao pingDao;

	@Override
	public Ping saveOrUpdatePing(Ping ping) {

		Date now = new Date();
		ping.setUpdateTime(now);
		if (ping.getId() == null) {
			ping.setCreateTime(now);
		}
		return pingDao.saveOrUpdatePing(ping);
	}

	@Override
	public Ping findPingById(Long id) {
		return pingDao.findPingById(id);
	}

	@Override
	public List<Ping> getPings() {
		return pingDao.getPings();
	}

	@Override
	public boolean deletePingById(Long id) {
		return pingDao.deletePingById(id);
	}

}
